<?php

/**
 * Category form.
 *
 * @package    cpfaizenay
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class CategoryForm extends BaseCategoryForm
{
  public function configure()
  {
      $user = sfContext::getInstance()->getUser()->getGuardUser();
      
      $dateWidget = new sfWidgetFormI18nDate(array(
          'format' => '%day%/%month%/%year%',
    //      'month_format' => 'short_name',
          'culture' => 'fr'
        ));

        if ($this->isNew()) {
            $this->widgetSchema['updated_at'] = new sfWidgetFormInputHidden();
            $this->widgetSchema['modification_user_id'] = new sfWidgetFormInputHidden();

            $this->setDefault('creation_user_id', $user->getId());
            $this->setDefault('modification_user_id', $user->getId());

            $this->setDefault('created_at', date('d-m-Y') );
            $this->setDefault('updated_at', date('d-m-Y') );
        }else{
            $this->widgetSchema['updated_at'] = new sfWidgetFormJQueryDate(array(
              'culture' => 'fr',
              'date_widget' => $dateWidget,
              'image' => '/images/admin/icons/small/calendar.png',
              'config' => '{}',
            ));
            $this->getObject()->set('modification_user_id', $user->getId());
        }

        $this->widgetSchema['created_at'] = new sfWidgetFormJQueryDate(array(
          'culture' => 'fr',
          'date_widget' => $dateWidget,
          'image' => '/images/admin/icons/small/calendar.png',
          'config' => '{}',
        ));

     $this->widgetSchema['type'] = new sfWidgetFormInputHidden();

//     $this->setWidget( 'aSfAssetCategory' , new sfWidgetFormDoctrineChoice(array(
//          'model'           =>  'Lieu',
//          'add_empty'       =>  false,
//          'multiple'        =>  true,
//          'expanded'        =>  true
//      )));

  }

  public function updateObject($values = null)
  {
    $object = parent::updateObject();
//    $type = $this->getOption('type');
//    $object->setType($type);
  }

}
